<template>
  <div id="CompanyAddDialog">
    <el-dialog title="添加企业" width="900px" :visible.sync="show">
      <vj-form @submit="onSubmit" @close="show=false" hide-reset :style-config="{labelWidth:'160px'}"
               :slot-idx="cfgList.length"
               :loading="loading" class="vj-form" :cfg-list="cfgList"
               :form-data.sync="formData"/>
    </el-dialog>
  </div>
</template>
<script lang="ts">
import Vue, {ComponentOptions, VueConstructor} from "vue"
import Component from 'vue-class-component'
import {Mixins} from "vue-property-decorator";
import {FormMixin} from "@/plugins/mixins/form";
import {ActivityFormTB} from "@/config/table";
import {
  ACTIVITY_FM,
  ACTIVITY_LINK_FM,
  CAPITAL_FM, COMPANY_ADD_FM,
  COMPANY_FM,
  disableFMAll,
  JOB_FM,
  PIC_FM,
  TALENT_FM
} from "@/config/form";
import {cloneDeep, formatOptions, hookSubmit, updateCfgOption} from "vijay-util";
import {requestByGet, requestByPost, requestByPut} from "@/utils/request";

@Component
export default class CompanyAddDialog extends Mixins(FormMixin) implements ComponentOptions<Vue> {
  name = "CompanyAddDialog"
  show = false;
  editId = null;
  formData = {};
  cfgList = COMPANY_ADD_FM(0)

  @hookSubmit()
  async onSubmit() {
    const requestFn = this.editId ? requestByPut : requestByPost;
    await requestFn(`qqc/qqcBusiness/${this.editId ? 'edit' : 'add'}`, {...this.formData, id: this.editId});
    this.$message.success("操作成功！");
    this.show = false;
    this.$emit('refresh')
  }


  open(data = {} as any) {
    this.show = true;
    this.formData = cloneDeep(data);
    this.editId = data.id;

  }


}
</script>

<style scoped lang="scss">
@import "~assets/common.scss";

#CompanyAddDialog {
}
</style>
